package com.huawei.appgallery.purchasehistory.ui.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.huawei.appgallery.foundation.store.bean.detail.DetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.foundation.ui.framework.widget.NodataWarnLayout;
import com.huawei.appgallery.foundation.ui.framework.widget.NodataWarnLayout.e;
import com.huawei.appgallery.purchasehistory.api.AppTracesListFragmentProtocol;
import com.huawei.appgallery.purchasehistory.api.AppTracesListFragmentProtocol.Request;
import com.huawei.appgallery.purchasehistory.impl.PurchaseHistoryManager;
import java.util.List;
import o.cfv;
import o.cfw;
import o.csp;
import o.cst.b;
import o.cst.h;
import o.csx;
import o.csz;
import o.ctf;
import o.ctj;
import o.ctk;
import o.ctm;
import o.ctn;
import o.ctp;
import o.ctr;
import o.cvt;
import o.dgm;
import o.dof;

public class PurchaseHistoryFragment extends AppListFragment<AppTracesListFragmentProtocol> implements ctn, ctk, ctp {
    private boolean ˊ = false;
    private boolean ॱॱ = false;
    private String ᐝ;
    private Activity ﾟ;

    class a implements Runnable {
        final /* synthetic */ PurchaseHistoryFragment ˊ;

        private a(PurchaseHistoryFragment purchaseHistoryFragment) {
            this.ˊ = purchaseHistoryFragment;
        }

        public void run() {
            if (this.ˊ.י != null) {
                ctr.ˋ(this.ˊ.י);
                this.ˊ.י.ͺ();
            }
            ctr.ˏ(this.ˊ.ﾟ);
            if (!this.ˊ.י()) {
                if (this.ˊ.ߴ == null || this.ˊ.ͺˎ == null) {
                    csp.ˏ.ˋ("PurchaseHistoryFragment", "no data");
                    return;
                }
                this.ˊ.ߴ.setWarnTextOne(h.ॱˊ);
                this.ˊ.ͺˎ.setEmptyView(this.ˊ.ߴ);
            }
        }
    }

    public void ˏ(Bundle bundle) {
        AppTracesListFragmentProtocol appTracesListFragmentProtocol = (AppTracesListFragmentProtocol) ˆ();
        if (appTracesListFragmentProtocol == null || appTracesListFragmentProtocol.ॱ() == null) {
            csp.ˏ.ˊ("PurchaseHistoryFragment", "onCreate AppTracesListFragmentProtocol is null or Request is null!");
        } else {
            this.ᐝ = ((Request) appTracesListFragmentProtocol.ॱ()).ˌ();
            this.ˊ = ((Request) appTracesListFragmentProtocol.ॱ()).ˋᐝ();
        }
        super.ˏ(bundle);
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.ﾟ = ॱˋ();
        if (this.ﾟ instanceof ctm) {
            ((ctm) this.ﾟ).ˎ(this);
        }
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        this.ͺˎ.ˊॱ().setVisibility(8);
        return ˋ;
    }

    public void ॱ(NodataWarnLayout nodataWarnLayout) {
        if (nodataWarnLayout != null) {
            nodataWarnLayout.setWarnImage(b.ˊ);
            nodataWarnLayout.setWarnTextOne(h.ॱˋ);
            nodataWarnLayout.setViewVisible(e.WARN_BTN, 8);
            nodataWarnLayout.setViewVisible(e.WARN_TEXTTWO, 8);
        }
    }

    public cfv ˏ(String str, String str2, int i) {
        cfv ˏ = csx.ˏ(str2, i);
        ˏ.setServiceType_(dgm.ˎ(this.ﾟ));
        return ˏ;
    }

    public void ˊʻ() {
        PurchaseHistoryManager.getHelper().ˏ(this.ﾟ, this.ᐝ, this.ˊ);
    }

    public void ٴ() {
        PurchaseHistoryManager.getHelper().ˊ(this.ﾟ, this.ᐝ, this.ˊ);
    }

    public void ˎˎ() {
        if (this.ﾟ instanceof ctm) {
            ((ctm) this.ﾟ).ˊ(this);
        }
        super.ˎˎ();
    }

    public void ˌ() {
        super.ˌ();
        this.ॱॱ = false;
    }

    public void ˋᐝ() {
        super.ˋᐝ();
        this.ॱॱ = true;
    }

    public void ˎ(String str) {
        if (!dof.ˎ(str, "android.intent.action.PACKAGE_ADDED")) {
            this.ˏ = 1;
            this.י.ॱॱ();
            this.י.ˊ(true);
            csp.ˏ.ˋ("PurchaseHistoryFragment", "trace has changed,get the new data from network!!!");
            ʿˊ();
        } else if (this.ˊ) {
            new Handler().postDelayed(new a(), 100);
        } else if (this.י == null) {
            csp.ˏ.ˋ("PurchaseHistoryFragment", "null == provider");
        } else {
            ctr.ॱ(this.ﾟ, ctr.ˏ(this.י), false);
        }
    }

    public boolean י() {
        return this.י == null || this.י.ˊॱ() != 0;
    }

    public boolean ˊ(TaskFragment taskFragment, TaskFragment.b bVar) {
        DetailResponse detailResponse = (DetailResponse) bVar.ˋ;
        List ᐝॱ = detailResponse.ᐝॱ();
        if (!ॱ(detailResponse.getResponseCode(), detailResponse.getRtnCode_())) {
            return super.ˊ(taskFragment, bVar);
        }
        ctr.ˋ(ᐝॱ, false, this.ˊ);
        ctr.ˎ(this.ﾟ, detailResponse, false);
        if (this.ˏ == 1 && this.ॱॱ) {
            this.ͺˎ.setAdapter(this.ـॱ);
        }
        super.ˊ(taskFragment, bVar);
        this.ˏ = ((cfv) bVar.ˊ).ˏ() + 1;
        ctr.ˏ(this.ﾟ);
        if (this.ˏ == 2) {
            if (this.ͺˎ != null) {
                this.ͺˎ.ˊॱ().setVisibility(0);
            }
            ߺ();
        }
        if (this.י.ˊॱ() == 0 && this.י.ᐝ()) {
            csp.ˏ.ˋ("PurchaseHistoryFragment", " auto load next page nextPageNum=" + this.ˏ);
            ʿˊ();
        }
        return false;
    }

    private void ߺ() {
        cvt o_csz = new csz();
        o_csz.setServiceType_(dgm.ˎ(this.ﾟ));
        cfw.ˎ(o_csz, new ctf(this.י));
    }

    public void ʼᐝ() {
        super.ʼᐝ();
        csp.ˏ.ˋ("PurchaseHistoryFragment", " onLoadingRetry");
        if (this.ﾟ instanceof ctj) {
            ((ctj) this.ﾟ).ˉ();
        }
    }

    public void ʿˊ() {
        super.ʿˊ();
        csp.ˏ.ˋ("PurchaseHistoryFragment", "execute");
    }
}
